﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdCmColor : OdCmColorBase
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdCmColor(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdCmColor_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdCmColor obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdCmColor()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdCmColor(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public override string ToString()
		{
			if (this.swigCPtr.Handle == IntPtr.Zero)
			{
				return "Empty";
			}
			string result = "???";
			if (this.isByLayer())
			{
				result = "ByLayer";
			}
			else if (this.isByBlock())
			{
				result = "ByBlock";
			}
			else if (this.isForeground())
			{
				result = "Foreground";
			}
			else if (this.isNone())
			{
				result = "None";
			}
			else if (this.isByACI())
			{
				result = string.Format("ACI = {0}", this.colorIndex());
			}
			else if (this.isByColor())
			{
				result = string.Concat(new string[]
				{
					"ByColor r",
					this.red().ToString(),
					":g",
					this.green().ToString(),
					":b",
					this.blue().ToString()
				});
			}
			return result;
		}

		public OdCmColor() : this(TD_DbPINVOKE.new_OdCmColor__SWIG_0(), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdCmColor(OdCmColor color) : this(TD_DbPINVOKE.new_OdCmColor__SWIG_1(OdCmColor.getCPtr(color)), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdCmColor(OdCmColorBase color) : this(TD_DbPINVOKE.new_OdCmColor__SWIG_2(OdCmColorBase.getCPtr(color)), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdCmColor(OdCmEntityColor.ColorMethod color) : this(TD_DbPINVOKE.new_OdCmColor__SWIG_3((int)color), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdCmColor Assign(OdCmColor color)
		{
			OdCmColor result = new OdCmColor(TD_DbPINVOKE.OdCmColor_Assign__SWIG_0(this.swigCPtr, OdCmColor.getCPtr(color)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdCmColor Assign(OdCmColorBase color)
		{
			OdCmColor result = new OdCmColor(TD_DbPINVOKE.OdCmColor_Assign__SWIG_1(this.swigCPtr, OdCmColorBase.getCPtr(color)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool IsEqual(OdCmColor color)
		{
			bool result = TD_DbPINVOKE.OdCmColor_IsEqual__SWIG_0(this.swigCPtr, OdCmColor.getCPtr(color));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool IsEqual(OdCmColorBase color)
		{
			bool result = TD_DbPINVOKE.OdCmColor_IsEqual__SWIG_1(this.swigCPtr, OdCmColorBase.getCPtr(color));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool IsNotEqual(OdCmColor color)
		{
			bool result = TD_DbPINVOKE.OdCmColor_IsNotEqual__SWIG_0(this.swigCPtr, OdCmColor.getCPtr(color));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool IsNotEqual(OdCmColorBase color)
		{
			bool result = TD_DbPINVOKE.OdCmColor_IsNotEqual__SWIG_1(this.swigCPtr, OdCmColorBase.getCPtr(color));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public string getDescription()
		{
			string result = TD_DbPINVOKE.OdCmColor_getDescription(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public string getExplanation()
		{
			string result = TD_DbPINVOKE.OdCmColor_getExplanation(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdCmEntityColor.ColorMethod colorMethod()
		{
			OdCmEntityColor.ColorMethod result = (OdCmEntityColor.ColorMethod)TD_DbPINVOKE.OdCmColor_colorMethod(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void setColorMethod(OdCmEntityColor.ColorMethod colorMethod)
		{
			TD_DbPINVOKE.OdCmColor_setColorMethod(this.swigCPtr, (int)colorMethod);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual bool isByColor()
		{
			bool result = TD_DbPINVOKE.OdCmColor_isByColor(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool isByLayer()
		{
			bool result = TD_DbPINVOKE.OdCmColor_isByLayer(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool isByBlock()
		{
			bool result = TD_DbPINVOKE.OdCmColor_isByBlock(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool isByACI()
		{
			bool result = TD_DbPINVOKE.OdCmColor_isByACI(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool isForeground()
		{
			bool result = TD_DbPINVOKE.OdCmColor_isForeground(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool isByDgnIndex()
		{
			bool result = TD_DbPINVOKE.OdCmColor_isByDgnIndex(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isNone()
		{
			bool result = TD_DbPINVOKE.OdCmColor_isNone(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual uint color()
		{
			uint result = TD_DbPINVOKE.OdCmColor_color(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void setColor(uint color)
		{
			TD_DbPINVOKE.OdCmColor_setColor(this.swigCPtr, color);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void setRGB(byte red, byte green, byte blue)
		{
			TD_DbPINVOKE.OdCmColor_setRGB(this.swigCPtr, red, green, blue);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void setRed(byte red)
		{
			TD_DbPINVOKE.OdCmColor_setRed(this.swigCPtr, red);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void setGreen(byte green)
		{
			TD_DbPINVOKE.OdCmColor_setGreen(this.swigCPtr, green);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void setBlue(byte blue)
		{
			TD_DbPINVOKE.OdCmColor_setBlue(this.swigCPtr, blue);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual byte red()
		{
			byte result = TD_DbPINVOKE.OdCmColor_red(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual byte green()
		{
			byte result = TD_DbPINVOKE.OdCmColor_green(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual byte blue()
		{
			byte result = TD_DbPINVOKE.OdCmColor_blue(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual ushort colorIndex()
		{
			ushort result = TD_DbPINVOKE.OdCmColor_colorIndex(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void setColorIndex(ushort colorIndex)
		{
			TD_DbPINVOKE.OdCmColor_setColorIndex(this.swigCPtr, colorIndex);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual bool setNames(string colorName, string bookName)
		{
			bool result = TD_DbPINVOKE.OdCmColor_setNames__SWIG_0(this.swigCPtr, colorName, bookName);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool setNames(string colorName)
		{
			bool result = TD_DbPINVOKE.OdCmColor_setNames__SWIG_1(this.swigCPtr, colorName);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual string colorName()
		{
			string result = TD_DbPINVOKE.OdCmColor_colorName(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual string bookName()
		{
			string result = TD_DbPINVOKE.OdCmColor_bookName(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual string colorNameForDisplay()
		{
			string result = TD_DbPINVOKE.OdCmColor_colorNameForDisplay(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdCmEntityColor entityColor()
		{
			OdCmEntityColor result = new OdCmEntityColor(TD_DbPINVOKE.OdCmColor_entityColor(this.swigCPtr), true);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public string getDictionaryKey()
		{
			string result = TD_DbPINVOKE.OdCmColor_getDictionaryKey(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool setNamesFromDictionaryKey(string dictionaryKey)
		{
			bool result = TD_DbPINVOKE.OdCmColor_setNamesFromDictionaryKey(this.swigCPtr, dictionaryKey);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void dwgIn(OdDbDwgFiler pFiler)
		{
			TD_DbPINVOKE.OdCmColor_dwgIn(this.swigCPtr, OdDbDwgFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void dwgOut(OdDbDwgFiler pFiler)
		{
			TD_DbPINVOKE.OdCmColor_dwgOut(this.swigCPtr, OdDbDwgFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void dxfIn(OdDbDxfFiler pFiler, int groupCodeOffset)
		{
			TD_DbPINVOKE.OdCmColor_dxfIn__SWIG_0(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler), groupCodeOffset);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void dxfIn(OdDbDxfFiler pFiler)
		{
			TD_DbPINVOKE.OdCmColor_dxfIn__SWIG_1(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void dxfOut(OdDbDxfFiler pFiler, int groupCodeOffset)
		{
			TD_DbPINVOKE.OdCmColor_dxfOut__SWIG_0(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler), groupCodeOffset);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void dxfOut(OdDbDxfFiler pFiler)
		{
			TD_DbPINVOKE.OdCmColor_dxfOut__SWIG_1(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void audit(OdDbAuditInfo pAuditInfo)
		{
			TD_DbPINVOKE.OdCmColor_audit(this.swigCPtr, OdDbAuditInfo.getCPtr(pAuditInfo));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void dwgInAsTrueColor(OdDbDwgFiler pFiler)
		{
			TD_DbPINVOKE.OdCmColor_dwgInAsTrueColor(this.swigCPtr, OdDbDwgFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void dwgOutAsTrueColor(OdDbDwgFiler pFiler)
		{
			TD_DbPINVOKE.OdCmColor_dwgOutAsTrueColor(this.swigCPtr, OdDbDwgFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static ushort MaxColorIndex
		{
			get
			{
				ushort result = TD_DbPINVOKE.OdCmColor_MaxColorIndex_get();
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
